package com.bokee.archerwq.lab.thread;

class A {
}

class T1 extends Thread {
	private A a;

	public T1(A a) {
		this.a = a;
	}

	@Override
	public void run() {
		System.out.println("T1 run begin");
		synchronized (a) {
			try {
				Thread.sleep(10000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			a.notifyAll();
		}
		System.out.println("T1 run end");
	}
}

class T2 extends Thread {
	private A a;

	public T2(A a) {
		this.a = a;
	}

	@Override
	public void run() {
		System.out.println("T2 run begin");
		try {
			synchronized (a) {
				a.wait();
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("in T2.run!");
		System.out.println("T2 run end");
	}
}

public class MorganTesting {

	public static void main(String[] args) {
		A a = new A();
		new T1(a).start();
		new T2(a).start();
	}

}
